unit RExtratoConta;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, RLReport, StdCtrls;

type
  TFormRExtratoConta = class(TForm)
    RLReport1: TRLReport;
    RLBand1: TRLBand;
    RLLabel1: TRLLabel;
    RLSystemInfo1: TRLSystemInfo;
    RLLabel12: TRLLabel;
    RLLabel2: TRLLabel;
    lblDatafim: TRLLabel;
    lblDataIni: TRLLabel;
    RLLabel4: TRLLabel;
    RLGroup1: TRLGroup;
    RLBand2: TRLBand;
    RLGroup2: TRLGroup;
    RLBand3: TRLBand;
    RLBand4: TRLBand;
    RLBand5: TRLBand;
    RLDBText1: TRLDBText;
    RLDBText2: TRLDBText;
    RLDBText3: TRLDBText;
    RLDBText4: TRLDBText;
    RLDBText5: TRLDBText;
    RLDBText6: TRLDBText;
    lblSaldo: TRLLabel;
    lblSaldoReal: TRLLabel;
    RLLabel3: TRLLabel;
    RLLabel5: TRLLabel;
    RLLabel6: TRLLabel;
    RLLabel7: TRLLabel;
    RLLabel8: TRLLabel;
    RLLabel10: TRLLabel;
    RLLabel11: TRLLabel;
    RLLabel13: TRLLabel;
    RLLabel9: TRLLabel;
    RLDBText7: TRLDBText;
    procedure RLBand4BeforePrint(Sender: TObject; var PrintIt: Boolean);
    procedure RLReport1BeforePrint(Sender: TObject; var PrintIt: Boolean);
    procedure lblSaldoBeforePrint(Sender: TObject; var Text: String;
      var PrintIt: Boolean);
    procedure lblSaldoRealBeforePrint(Sender: TObject; var Text: String;
      var PrintIt: Boolean);
    procedure RLDBText7BeforePrint(Sender: TObject; var Text: String;
      var PrintIt: Boolean);
  private
    { Private declarations }
    Saldo, SaldoReal : Real;
  public
    { Public declarations }
  end;

var
  FormRExtratoConta: TFormRExtratoConta;

implementation

uses DMR, DB, Geral;

{$R *.dfm}

procedure TFormRExtratoConta.RLBand4BeforePrint(Sender: TObject;
  var PrintIt: Boolean);
begin
    with RLReport1.DataSource.DataSet do
    begin
        if FieldByName('PENDENTE').AsInteger = -1 then
        begin
            if FieldByName('TIPO').AsString = 'C' then
                SaldoReal := SaldoReal + FieldbyName('VALOR').AsFloat
            else
                SaldoReal := SaldoReal - FieldbyName('VALOR').AsFloat;
        end
        else
        begin
            if FieldByName('TIPO').AsString = 'C' then
                Saldo := Saldo + FieldbyName('VALOR').AsFloat
            else
                Saldo := Saldo - FieldbyName('VALOR').AsFloat;
        end;
        if FieldByName('PENDENTE').AsInteger = -1 then
            PrintIt := False;
    end;
end;

procedure TFormRExtratoConta.RLReport1BeforePrint(Sender: TObject;
  var PrintIt: Boolean);
begin
    Saldo := 0;
    SaldoReal := 0;
end;

procedure TFormRExtratoConta.lblSaldoBeforePrint(Sender: TObject;
  var Text: String; var PrintIt: Boolean);
begin
    Text := currtostrf(Saldo, ffCurrency, 2);
end;

procedure TFormRExtratoConta.lblSaldoRealBeforePrint(Sender: TObject;
  var Text: String; var PrintIt: Boolean);
begin
    Text := currtostrf((Saldo)+(SaldoReal), ffCurrency, 2);
end;

procedure TFormRExtratoConta.RLDBText7BeforePrint(Sender: TObject;
  var Text: String; var PrintIt: Boolean);
begin
    Text := GetCampoQuery('CHEQUE','NUMEROCHEQUE','CODTRANSACAO', DMRel.dsRelat.DataSet.FieldByName('CODTRANSACAO').AsString);
end;

end.
